home *** CD-ROM | disk | FTP | other *** search
/ Nautilus 1992 July / Nautilus-3-8 / Nautilus-3-8.bin / Tools & Utilities / Techy Stuff / Doco ƒ / CSMP ƒ / CSMP-V1-074.TXT < prev    next >
Encoding:
Text File  |  1992-06-04  |  45.5 KB  |  1,245 lines

  1. C.S.M.P. Digest             Fri, 08 May 92       Volume 1 : Issue 74
  2.  
  3. Today's Topics:
  4.  
  5.     CDEF values while tracking
  6.     Trouble initializing structures in THINK C 5.0.2
  7.     SADE en MPW
  8.     Where are HD icons stored?
  9.     fortran object files
  10.     How to copy resource file?
  11.     Hard drive icons?
  12.     Very Early Macintosh Systre
  13.     GWorld Woes
  14.     Looking for C++ Compiler for Mac
  15.     Macintosh C Programming primer examples (Q) Where?
  16.     Problem with THINK C 5.0.2 (long)
  17.  
  18.  
  19. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  20.  
  21. These digests are available (by using FTP, account anonymous, your email
  22. address as password) in the pub/mac/csmp-digest directory on ftp.cs.uoregon.
  23. edu.  This is also the home of the comp.sys.mac.programmer Frequently Asked
  24. Questions list.  The last several issues of the digest are available from
  25. sumex-aim.stanford.edu as well.
  26.  
  27. These digests are also available via email.  Just send a note saying that you
  28. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  29. automatically receive each new digest as it is created.
  30.  
  31. The digest is a collection of articles from the internet newsgroup comp.sys.
  32. mac.programmer.  It is designed for people who read c.s.m.p. semi-regularly
  33. and want an archive of the discussions.  If you don't know what a newsgroup
  34. is, you probably don't have access to it.  Ask your systems administrator(s)
  35. for details.  (This means you can't post questions to the digest.)
  36.  
  37. The articles in these digests are taken directly from comp.sys.mac.programmer.
  38. They are not edited; all articles included in this digest are in their original
  39. posted form.  The only articles that are -not- included in these digests are
  40. those which didn't receive any replies (except those that give information
  41. rather than ask a question).  All replies to each article are concatenated
  42. onto the original article in the order in which they were received.  Article
  43. threads are not added to the digests until the last article added to the
  44. thread is at least one month old (this is to ensure that the thread is dead
  45. before adding it to the digests).
  46.  
  47. Send administrative mail to mkelly@cs.uoregon.edu.
  48.  
  49. -------------------------------------------------------
  50.  
  51. From: u2005681@ucsvc.ucs.unimelb.edu.au
  52. Subject: CDEF values while tracking
  53. Date: 28 Mar 92 05:58:28 GMT
  54. Organization: The University of Melbourne
  55.  
  56. I have recently been messing around with some CDEFs to create a sliding lever
  57. not unlike the one that can be found in the sound control panel. Next to the
  58. sliding lever is an edit field which displays the value of the CDEF. However,
  59. the value is only updated when TrackControl (called via ModalDIalog) senses
  60. that the user has released the mouse button. This is of not much use.
  61. Application such as SuperPaint (trade mark blah, blah, blah...) manage to
  62. update the edit field while the user is moving the control. How do they do it?
  63. I would be eternally grateful to anyone who could give me some examples and
  64. maybe an explanation to go with it.
  65.  
  66. Thanks in advance :-)
  67.  
  68. +++++++++++++++++++++++++++
  69.  
  70. From: f85-tno@nada.kth.se (Tommy Nordgren)
  71. Date: 6 Apr 92 15:23:36 GMT
  72. Organization: Royal Institute of Technology, Stockholm, Sweden
  73.  
  74. In article <1992Mar28.155828.2949@ucsvc.ucs.unimelb.edu.au>, u2005681@ucsvc.ucs.unimelb.edu.au writes:
  75. |> I have recently been messing around with some CDEFs to create a sliding lever
  76. |> not unlike the one that can be found in the sound control panel. Next to the
  77. |> sliding lever is an edit field which displays the value of the CDEF. However,
  78. |> the value is only updated when TrackControl (called via ModalDIalog) senses
  79. |> that the user has released the mouse button. This is of not much use.
  80. |> Application such as SuperPaint (trade mark blah, blah, blah...) manage to
  81. |> update the edit field while the user is moving the control. How do they do it?
  82. |> I would be eternally grateful to anyone who could give me some examples and
  83. |> maybe an explanation to go with it.
  84. |> 
  85. |> Thanks in advance :-)
  86. You must:
  87. 1. Use a dialog filter function.
  88. 2. When the filter function detects a mouse click in the control, track the 
  89.    control yourself, using a custom tracking procedure.
  90. 3. Some notes. The port is NOT automatically set up when your filter function is
  91. called. FindDItem returns a Zero-based number. Other dialog manager routines
  92. expect a One-based number as argument.
  93.  
  94. +++++++++++++++++++++++++++
  95.  
  96. From: f85-tno@nada.kth.se (Tommy Nordgren)
  97. Date: 6 Apr 92 15:23:36 GMT
  98. Organization: Royal Institute of Technology, Stockholm, Sweden
  99.  
  100. In article <1992Mar28.155828.2949@ucsvc.ucs.unimelb.edu.au>, u2005681@ucsvc.ucs.unimelb.edu.au writes:
  101. |> I have recently been messing around with some CDEFs to create a sliding lever
  102. |> not unlike the one that can be found in the sound control panel. Next to the
  103. |> sliding lever is an edit field which displays the value of the CDEF. However,
  104. |> the value is only updated when TrackControl (called via ModalDIalog) senses
  105. |> that the user has released the mouse button. This is of not much use.
  106. |> Application such as SuperPaint (trade mark blah, blah, blah...) manage to
  107. |> update the edit field while the user is moving the control. How do they do it?
  108. |> I would be eternally grateful to anyone who could give me some examples and
  109. |> maybe an explanation to go with it.
  110. |> 
  111. |> Thanks in advance :-)
  112. You must:
  113. 1. Use a dialog filter function.
  114. 2. When the filter function detects a mouse click in the control, track the 
  115.    control yourself, using a custom tracking procedure.
  116. 3. Some notes. The port is NOT automatically set up when your filter function is
  117. called. FindDItem returns a Zero-based number. Other dialog manager routines
  118. expect a One-based number as argument.
  119.  
  120. ---------------------------
  121.  
  122. From: frain@cis.ksu.edu (Jerry Frain)
  123. Subject: Trouble initializing structures in THINK C 5.0.2
  124. Date: 30 Mar 1992 02:58:55 GMT
  125. Organization: Kansas State University, Dept. of Computing and Information Sciences
  126.  
  127.  
  128. My apologies if this has been thrashed before, and I missed it.
  129.  
  130. Can anyone tell me why the following is correct
  131.  
  132.     struct foo {
  133.         int a;
  134.         int b;
  135.     };
  136.     struct foo bar[2] = {{1, 2}, {3, 4}};
  137.  
  138. And yet this is not:
  139.  
  140.     struct foo {
  141.         char *a;
  142.         char *b;
  143.     };
  144.     struct foo bar[2] = {{"1", "2"}, {"3", "4"}};
  145.  
  146. I get "illegal initialization" when compiling the above.  Did I miss
  147. something in the documentation about THINK C 5.0.2 not being able to
  148. do aggregate initialization of strings?
  149.  
  150. BTW, the initialization was *not* attempted in the body of a function
  151. (if that was your first guess).
  152.  
  153. The above structure initialization compiled (and ran) fine using Sun
  154. cc and gcc.
  155.  
  156.   --Jerry Frain, frain@cis.ksu.edu
  157.  
  158.  
  159.  
  160. +++++++++++++++++++++++++++
  161.  
  162. From: frain@cis.ksu.edu (Jerry Frain)
  163. Date: 30 Mar 92 06:58:41 GMT
  164. Organization: Kansas State University
  165.  
  166. frain@cis.ksu.edu (Jerry Frain) writes:
  167. >     struct foo {
  168. >         char *a;
  169. >         char *b;
  170. >     };
  171. >     struct foo bar[2] = {{"1", "2"}, {"3", "4"}};
  172.  
  173. > I get "illegal initialization" when compiling the above.  Did I miss
  174. > something in the documentation about THINK C 5.0.2 not being able to
  175. > do aggregate initialization of strings?
  176.  
  177. Turns out that the above code only works if the project type is an
  178. application, I was making a code resource.
  179.  
  180.   --Jerry Frain, frain@cis.ksu.edu
  181.  
  182. +++++++++++++++++++++++++++
  183.  
  184. From: Keith_Rollin@taligent.com (Keith Rollin)
  185. Date: 30 Mar 92 23:07:38 GMT
  186. Organization: Taligent
  187.  
  188. In article <frain.701938788@depot.cis.ksu.edu>, frain@cis.ksu.edu (Jerry Frain) writes:
  189. > frain@cis.ksu.edu (Jerry Frain) writes:
  190. > >     struct foo {
  191. > >         char *a;
  192. > >         char *b;
  193. > >     };
  194. > >     struct foo bar[2] = {{"1", "2"}, {"3", "4"}};
  195. > > I get "illegal initialization" when compiling the above.  Did I miss
  196. > > something in the documentation about THINK C 5.0.2 not being able to
  197. > > do aggregate initialization of strings?
  198. > Turns out that the above code only works if the project type is an
  199. > application, I was making a code resource.
  200.  
  201. That's right. The reason for this is because you are trying to
  202. initialize the array with pointers to strings. These pointers
  203. take the form of absolute memory locations. There is no way to
  204. determine these absolute memory locations at compile time. Applications
  205. take care of patching up the pointers when they are launched through
  206. some runtime support routines (in MPW, the routine is __DATAINIT. Under
  207. THINK, I think it's through the DATA resource, but that's just a wild
  208. guess). There are no such runtime support routines for standalone
  209. code, and, even if there were, they'd have to take into account the
  210. fact that standalone code resources can be unlocked and moved around
  211. in memory, invalidating the string pointers.
  212.  
  213. +++++++++++++++++++++++++++
  214.  
  215. From: Steve Creps <creps@silver.ucs.indiana.edu>
  216. Organization: Indiana University
  217. Date: Mon, 6 Apr 1992 10:01:10 -0500
  218.  
  219. In article <frain.701924552@depot.cis.ksu.edu> frain@cis.ksu.edu (Jerry Frain) writes:
  220. >Can anyone tell me why the following is correct
  221. >
  222. >    struct foo {
  223. >        int a;
  224. >        int b;
  225. >    };
  226. >    struct foo bar[2] = {{1, 2}, {3, 4}};
  227. >
  228. >And yet this is not:
  229. >
  230. >    struct foo {
  231. >        char *a;
  232. >        char *b;
  233. >    };
  234. >    struct foo bar[2] = {{"1", "2"}, {"3", "4"}};
  235.  
  236.    I've not used Think C.  However, this is not specifically a Mac programming
  237. problem, but rather a general C programming problem.
  238.  
  239.    In Example 1 all the memory locations get allocated because there are no
  240. pointers used (unless you want to get technical).  Both fields in struct foo
  241. are int, so when you declare a variable as struct foo, the memory locations
  242. to hold both a and b are allocated.
  243.  
  244.    In Example 2, however, you are declaring the fields of foo as _pointers_,
  245. so all that gets allocated are places to hold addresses of places to hold
  246. characters.  Note that "char *a" doesn't tell how big the string is.
  247. Declaring it "char a[2]" would work, because that would actually allocate
  248. two characters for the given string (including the zero terminator).
  249.  
  250.    Note the following similar examples:
  251.  
  252. Example 3:
  253.  
  254. int foo = 1;
  255.  
  256. Example 4:
  257.  
  258. char *foo = "1";
  259.  
  260.    Both of these, however, should work.  Example 4 works not because space is
  261. being allocated for the string, but because it is getting the address of the
  262. space _which has already been allocated_ to store the constant string "1".
  263.  
  264.    To summarize, the problem mentioned was caused by not making sure that
  265. space was being allocated for strings being used.  That problem is one of
  266. the most difficult concepts to master when learning C.
  267.  
  268. - -    -    -    -    -    -    -    -    -    -
  269. Steve Creps, Indiana University
  270. creps@silver.ucs.indiana.edu (129.79.1.6)
  271. {inuxc,rutgers,uunet!uiucdcs,pur-ee}!iuvax!silver!creps
  272.  
  273. +++++++++++++++++++++++++++
  274.  
  275. From: brian@galileo.jsc.nasa.gov (Brian Donnell)
  276. Date: 6 Apr 92 20:56:41 GMT
  277. Organization: NASA/JSC
  278.  
  279. In article <1992Apr6.100118.25393@bronze.ucs.indiana.edu>, Steve Creps <creps@silver.ucs.indiana.edu> writes:
  280. > In article <frain.701924552@depot.cis.ksu.edu> frain@cis.ksu.edu (Jerry Frain) writes:
  281. > >    struct foo {
  282. > >        char *a;
  283. > >        char *b;
  284. > >    };
  285. > >    struct foo bar[2] = {{"1", "2"}, {"3", "4"}};
  286. >    In Example 2, however, you are declaring the fields of foo as _pointers_,
  287. > so all that gets allocated are places to hold addresses of places to hold
  288. > characters.  Note that "char *a" doesn't tell how big the string is.
  289. > Declaring it "char a[2]" would work, because that would actually allocate
  290. > two characters for the given string (including the zero terminator).
  291.  
  292. No.  You are incorrect.  The above example is legitimate C.  As to why it
  293. does not work for the original poster in Think C, I don't know; it works
  294. for me.
  295.  
  296. The string literals are allocated in the static data space by the compiler,
  297. and the fields of the structure are assigned the addresses of those
  298. literal strings.
  299.  
  300. Brian Donnell
  301. NASA/JSC
  302.  
  303. +++++++++++++++++++++++++++
  304.  
  305. From: Steve Creps <creps@silver.ucs.indiana.edu>
  306. Organization: Indiana University
  307. Date: Mon, 6 Apr 1992 10:01:10 -0500
  308.  
  309. In article <frain.701924552@depot.cis.ksu.edu> frain@cis.ksu.edu (Jerry Frain) writes:
  310. >Can anyone tell me why the following is correct
  311. >
  312. >    struct foo {
  313. >        int a;
  314. >        int b;
  315. >    };
  316. >    struct foo bar[2] = {{1, 2}, {3, 4}};
  317. >
  318. >And yet this is not:
  319. >
  320. >    struct foo {
  321. >        char *a;
  322. >        char *b;
  323. >    };
  324. >    struct foo bar[2] = {{"1", "2"}, {"3", "4"}};
  325.  
  326.    I've not used Think C.  However, this is not specifically a Mac programming
  327. problem, but rather a general C programming problem.
  328.  
  329.    In Example 1 all the memory locations get allocated because there are no
  330. pointers used (unless you want to get technical).  Both fields in struct foo
  331. are int, so when you declare a variable as struct foo, the memory locations
  332. to hold both a and b are allocated.
  333.  
  334.    In Example 2, however, you are declaring the fields of foo as _pointers_,
  335. so all that gets allocated are places to hold addresses of places to hold
  336. characters.  Note that "char *a" doesn't tell how big the string is.
  337. Declaring it "char a[2]" would work, because that would actually allocate
  338. two characters for the given string (including the zero terminator).
  339.  
  340.    Note the following similar examples:
  341.  
  342. Example 3:
  343.  
  344. int foo = 1;
  345.  
  346. Example 4:
  347.  
  348. char *foo = "1";
  349.  
  350.    Both of these, however, should work.  Example 4 works not because space is
  351. being allocated for the string, but because it is getting the address of the
  352. space _which has already been allocated_ to store the constant string "1".
  353.  
  354.    To summarize, the problem mentioned was caused by not making sure that
  355. space was being allocated for strings being used.  That problem is one of
  356. the most difficult concepts to master when learning C.
  357.  
  358. - -    -    -    -    -    -    -    -    -    -
  359. Steve Creps, Indiana University
  360. creps@silver.ucs.indiana.edu (129.79.1.6)
  361. {inuxc,rutgers,uunet!uiucdcs,pur-ee}!iuvax!silver!creps
  362.  
  363. +++++++++++++++++++++++++++
  364.  
  365. From: brian@galileo.jsc.nasa.gov (Brian Donnell)
  366. Date: 6 Apr 92 20:56:41 GMT
  367. Organization: NASA/JSC
  368.  
  369. In article <1992Apr6.100118.25393@bronze.ucs.indiana.edu>, Steve Creps <creps@silver.ucs.indiana.edu> writes:
  370. > In article <frain.701924552@depot.cis.ksu.edu> frain@cis.ksu.edu (Jerry Frain) writes:
  371. > >    struct foo {
  372. > >        char *a;
  373. > >        char *b;
  374. > >    };
  375. > >    struct foo bar[2] = {{"1", "2"}, {"3", "4"}};
  376. >    In Example 2, however, you are declaring the fields of foo as _pointers_,
  377. > so all that gets allocated are places to hold addresses of places to hold
  378. > characters.  Note that "char *a" doesn't tell how big the string is.
  379. > Declaring it "char a[2]" would work, because that would actually allocate
  380. > two characters for the given string (including the zero terminator).
  381.  
  382. No.  You are incorrect.  The above example is legitimate C.  As to why it
  383. does not work for the original poster in Think C, I don't know; it works
  384. for me.
  385.  
  386. The string literals are allocated in the static data space by the compiler,
  387. and the fields of the structure are assigned the addresses of those
  388. literal strings.
  389.  
  390. Brian Donnell
  391. NASA/JSC
  392.  
  393. ---------------------------
  394.  
  395. From: fstiva@cs.vu.nl (Stiva F)
  396. Subject: SADE en MPW
  397. Date: 30 Mar 92 08:21:02 GMT
  398.  
  399.  
  400. Who can help me to solve the following two problems I encountered using MPW and SADE:
  401.  
  402. - - The linker generates:
  403.   LocalID has previous, conflicting type (error 85)
  404.   <bad object file or compiler errors>
  405.   The makefile looks like this:
  406.   Asm -Sym on  file.a
  407.   Link -Sym on  file1.a.o ... filen.a.o   -o prog
  408.   What is the problem?
  409.  
  410. - - In SADE the following error occurs trying to set a break in a source file:
  411.   Cannot determine break address: File "file" has corrupt symbol information
  412.   (file is a INCLUDE file in file.a with source code in it)
  413.   The project consists of a number of segments. The assembler source of each 
  414.   segment resides in its own folder.
  415.   Asm places the object codes in one object folder.
  416.   In SADE the source path variable is set to all the folders containing the
  417.   source files.
  418.   When I set the target on my program, every thing works fine. When I set a
  419.   breakpoint in the first segment everything works fine.
  420.   Setting a break in another segment produces the error.
  421.   Stepping into a procedure belonging to another segment produces the following
  422.   error:
  423.   search_page_tables() bad index, ((!object_table441eba) || (....))
  424.   Any suggestions?
  425.  
  426.   Thanks in advance.
  427.     Fulco Stiva (fstiva@cs.vu.nl)
  428.     Vrij Universiteit Amsterdam
  429.   
  430.  
  431. +++++++++++++++++++++++++++
  432.  
  433. From: ksand@apple.com (Kent Sandvik)
  434. Date: 5 Apr 92 23:24:37 GMT
  435. Organization: MacDTS Mongols
  436.  
  437. In article <13603@star.cs.vu.nl>, fstiva@cs.vu.nl (Stiva F) writes:
  438. > - The linker generates:
  439. >   LocalID has previous, conflicting type (error 85)
  440. >   <bad object file or compiler errors>
  441. >   The makefile looks like this:
  442. >   Asm -Sym on  file.a
  443. >   Link -Sym on  file1.a.o ... filen.a.o   -o prog
  444. >   What is the problem?
  445. Can't say exactly, are you using Link 3.2 and Asm 3.2, or a mix
  446. of releases (SYM format changed between releases, so for instance if 
  447. one of the other files was compiled long time ago it maybe has old
  448. SYM format information?
  449.  
  450. Cheers,
  451. Kent Sandvik/DTS
  452.  
  453. +++++++++++++++++++++++++++
  454.  
  455. From: ksand@apple.com (Kent Sandvik)
  456. Date: 5 Apr 92 23:24:37 GMT
  457. Organization: MacDTS Mongols
  458.  
  459. In article <13603@star.cs.vu.nl>, fstiva@cs.vu.nl (Stiva F) writes:
  460. > - The linker generates:
  461. >   LocalID has previous, conflicting type (error 85)
  462. >   <bad object file or compiler errors>
  463. >   The makefile looks like this:
  464. >   Asm -Sym on  file.a
  465. >   Link -Sym on  file1.a.o ... filen.a.o   -o prog
  466. >   What is the problem?
  467. Can't say exactly, are you using Link 3.2 and Asm 3.2, or a mix
  468. of releases (SYM format changed between releases, so for instance if 
  469. one of the other files was compiled long time ago it maybe has old
  470. SYM format information?
  471.  
  472. Cheers,
  473. Kent Sandvik/DTS
  474.  
  475. ---------------------------
  476.  
  477. From: yeongm2@aix.rpi.edu (Mengyik Yeong)
  478. Subject: Where are HD icons stored?
  479. Date: Fri, 3 Apr 1992 01:40:30 GMT
  480.  
  481. I am trying to write a program to read and display some information 
  482. on volumes.  What I would like to do is to display the information
  483. under the appropriate icon for the volume.  However I can't seem
  484. to find where the HD icons are stored.  I have examined the system,
  485. finder, desktop, startup device files.  Where do I have to look
  486. to copy the ICON (?) resource?
  487.  
  488. Mengyik
  489. yeongm2@rpi.edu
  490.  
  491.  
  492. +++++++++++++++++++++++++++
  493.  
  494. From: mwalker@wc.novell.com (Mel Walker)
  495. Organization: Novell, Inc. - Walnut Creek
  496. Date: Fri, 3 Apr 1992 15:20:49 GMT
  497.  
  498. In article <08wtt1_@rpi.edu> yeongm2@aix.rpi.edu (Mengyik Yeong) writes:
  499. >I am trying to write a program to read and display some information 
  500. >on volumes.  What I would like to do is to display the information
  501. >under the appropriate icon for the volume.  However I can't seem
  502. >to find where the HD icons are stored.  I have examined the system,
  503. >finder, desktop, startup device files.  Where do I have to look
  504. >to copy the ICON (?) resource?
  505. >
  506. >Mengyik
  507. >yeongm2@rpi.edu
  508. >
  509.  
  510. The "resources" for the HD icon(s) are in the HD driver code, I believe. Short
  511. of hacking into that, you can't copy the resources, although you could
  512. always get the picture under sys7.
  513.  
  514. +++++++++++++++++++++++++++
  515.  
  516. From: krapf@email.tuwien.ac.at (Stephan Bublava)
  517. Date: 4 Apr 92 12:24:02 GMT
  518. Organization: Fachschaft Informatik, TU Wien
  519.  
  520. In article <08wtt1_@rpi.edu> yeongm2@aix.rpi.edu (Mengyik Yeong) wrote:
  521.  
  522. >I am trying to write a program to read and display some information
  523. >on volumes.  What I would like to do is to display the information
  524. >under the appropriate icon for the volume.  However I can't seem
  525. >to find where the HD icons are stored.  I have examined the system,
  526. >finder, desktop, startup device files.  Where do I have to look
  527. >to copy the ICON (?) resource?
  528.  
  529. To my knowledge hard disk (as well as floppy disk) icons are stored
  530. in the driver (nor as resource) and also drawn by the driver.
  531.  
  532. Check out: TN 272 What your Sony drives for you
  533.  
  534. Since I do not have Inside Macintosh handy, i cannot look whether this
  535. topic is covered there, but volumes IV and/or V should have information
  536. about this.
  537.  
  538. Hope this helps
  539.  
  540. Stephan Bublava, krapf@email.tuwien.ac.at
  541.  
  542. +++++++++++++++++++++++++++
  543.  
  544. From: jpugh@apple.com (Jon Pugh)
  545. Date: 6 Apr 92 23:27:26 GMT
  546. Organization: Apple Co.
  547.  
  548. In article <08wtt1_@rpi.edu>, yeongm2@aix.rpi.edu (Mengyik Yeong) writes:
  549. > I am trying to write a program to read and display some information 
  550. > on volumes.  What I would like to do is to display the information
  551. > under the appropriate icon for the volume.  
  552.  
  553. See IM IV-224.  It's the Disk Driver chapter which says that csCode 21 to 
  554. the driver returns an ICN#.
  555.  
  556. Of course, I've never done this, so there's probably more to it than this. ;)
  557.  
  558. Jon
  559.  
  560. +++++++++++++++++++++++++++
  561.  
  562. From: jpugh@apple.com (Jon Pugh)
  563. Date: 6 Apr 92 23:27:26 GMT
  564. Organization: Apple Co.
  565.  
  566. In article <08wtt1_@rpi.edu>, yeongm2@aix.rpi.edu (Mengyik Yeong) writes:
  567. > I am trying to write a program to read and display some information 
  568. > on volumes.  What I would like to do is to display the information
  569. > under the appropriate icon for the volume.  
  570.  
  571. See IM IV-224.  It's the Disk Driver chapter which says that csCode 21 to 
  572. the driver returns an ICN#.
  573.  
  574. Of course, I've never done this, so there's probably more to it than this. ;)
  575.  
  576. Jon
  577.  
  578. ---------------------------
  579.  
  580. From: udita@MV3600.BMEN.TULANE.EDU
  581. Subject: fortran object files
  582. Date: 3 Apr 92 21:16:15 GMT
  583. Organization: TULANE, BMEN, NEW ORLEANS, LA
  584.  
  585.  
  586. I have Language Systems fortran object files in my Think Pascal project.
  587. when i try to build it, i get an error"can't convert .o file". i have older
  588. fortran files that i recompiled and added to the pascal project and
  589. they do not cause any problems. as far as i can tell the fortran source code
  590. is not different in the way the subroutines are called or exited.
  591. i would really appreciate it if someone can help me with this.
  592. i have Think pascal 2.0 and LS fortran 3.0.
  593. Udita 
  594.  
  595. +++++++++++++++++++++++++++
  596.  
  597. From: walsteyn@fys.ruu.nl (Fred Walsteijn)
  598. Date: 4 Apr 92 22:17:31 GMT
  599. Organization: Physics Department, University of Utrecht,  The Netherlands
  600.  
  601. In <009588E9.E9611920@MV3600.BMEN.TULANE.EDU> udita@MV3600.BMEN.TULANE.EDU writes:
  602.  
  603. >I have Language Systems fortran object files in my Think Pascal project.
  604. >when i try to build it, i get an error"can't convert .o file". i have older
  605. >fortran files that i recompiled and added to the pascal project and
  606. >they do not cause any problems. as far as i can tell the fortran source code
  607. >is not different in the way the subroutines are called or exited.
  608. >i would really appreciate it if someone can help me with this.
  609. >i have Think pascal 2.0 and LS fortran 3.0.
  610. >Udita 
  611.  
  612. The object files produced by LS Fortran 2.1 and before are not compatible
  613. with LS Fortran 3.0.
  614. I had to recompile some libraries after I upgraded to LS Fortran 3.0.
  615. I have no experience with Fortran/Pascal linking (only LS Fortran and MPW C).
  616. Hope this is relevant,
  617. - -----------------------------------------------------------------------------
  618. Fred Walsteijn                                | Internet: walsteyn@fys.ruu.nl
  619. Institute for Marine and Atmospheric Research | FAX:      31-30-543163
  620. Utrecht University, The Netherlands           | Phone:    31-30-533169
  621. - -----------------------------------------------------------------------------
  622.  
  623. ---------------------------
  624.  
  625. From: derry@sfu.ca (Andrew Derry)
  626. Subject: How to copy resource file?
  627. Organization: Simon Fraser University
  628. Date: Fri, 3 Apr 1992 23:50:04 GMT
  629.  
  630. How do I copy a file that only has a resource fork?  I believe I've figgured
  631. out how to read the resource fork and how to create a new file, then write
  632. the resource fork to it... but then the creator and type are not the same.
  633. Is there a way to read the creator and type of the original to use when
  634. creating the copy?  Also, is there a way to tell when I've reached the
  635. end of the file when reading the original?
  636.  
  637. A quick example of making an exact duplicate of a file with a 0 length
  638. data fork and an arbitrarily long resource fork would be excellent, but
  639. any help would be appriciated.
  640.  
  641. Also, the source file will be on a remote appleshared system.  Will this
  642. be a problem? (will it make any difference?)
  643.  
  644. Thank you.
  645.  
  646.  
  647. Andrew
  648.  
  649. +++++++++++++++++++++++++++
  650.  
  651. Organization: Sophomore, Electrical and Computer Engineering, Carnegie Mellon, Pittsburgh, PA
  652. Date: Sat, 4 Apr 1992 03:16:56 -0500 
  653. From: "Jeffrey T. Hutzelman" <jh4o+@andrew.cmu.edu>
  654.  
  655. Steps for copying a file...
  656.  
  657. 1. Call HGetFInfo (GetFHInfo??) or PBGetCatInfo on the source file, to
  658. find out stuff about it
  659.  
  660. 2. Create the destination file
  661.  
  662. 3. Call HSetFInfo on the destination file.  Doing things in this order lets
  663. the destination file be in a DropBox.
  664.  
  665. 4. Open both the data and resource forks of the source, or at least open
  666. whatever you are going to use.
  667.  
  668. 5. Open both forks of the destination, or whichever you are going to use.
  669. Make sure if you are going to use both forks you OPEN both before writing
  670. to either; this maintains the ability to store into DropBoxes.
  671.  
  672. 6. You can use GetEOF and SetEOF to take care of the EOF's.  Calling SetEOF
  673. before actually writing any of it allows the system to allocate all the
  674. space at once, theoretically reducing fragmentation.  This becomes more
  675. important if the desintation file is on a fileserver (including the local
  676. machine running sharing), or in general if lots of programs will run at
  677. once, and might write to disk.  It's also generally a good idea.
  678.  
  679. 7. Read data and then write it, in large chunks (for efficiency), until you
  680. get an error saying there is no more.
  681.  
  682. 8. Close both forks of the destination file.
  683.  
  684. 9. If desired, call PBSetCatInfo on the destination to set the modify date to
  685. the same as the source.  Note that this step WILL fail if the destination was
  686. in a dropbox; you just have to ignore it.
  687.  
  688. Sample code follows...
  689.  
  690. On second thought, I'll post the sample source once I've written it.
  691. In the meantime, read the stuff in IM about FSRead; you'll find that
  692. 1.) It returns the error eofErr when you hit the end of the file.
  693. 2.) It returns a count of how many bytes it acutally read, as opposed to how
  694. many you requested.
  695.  
  696. - -- Jeffrey Hutzelman
  697.  
  698. jh4o+@andrew.cmu.edu, jhutz@drycas.BITNET, or JeffreyH11 on America Online
  699.  
  700. ---------------------------
  701.  
  702. From: rhorn@csws15.ic.sunysb.edu (Robert Horn)
  703. Subject: Hard drive icons?
  704. Organization: SUNY at Stony Brook where no one gets an education
  705. Date: Sat, 4 Apr 1992 03:19:47 GMT
  706.  
  707. Hi!
  708.  
  709. I'm writing a program, in which I have to get the icon for any 
  710. file/folder/disk. I know how to get icons for everything except a hard drive
  711. without a custom icon; I know that this information is in the hard drive's
  712. driver, and that I should be able to access it through the Control() function,
  713. something on the order of:
  714.  
  715.     csCode = 21;        /* get 'ICN#' thingy */
  716.     theErr = Control(magicNumber, csCode, buf);
  717.                 /* should this be a call to Status by any
  718.                    chance? */
  719.  
  720. What is the magicNumber? I've tried the drive number, the vRefNum, and a few
  721. fairly random things. IM-IV says that this will work for a Apple 20 Meg drive,
  722. does this work for all hard drives?
  723.  
  724. Thanks in advance for any help,
  725. Rob
  726.  
  727. - ---
  728. rhorn@ic.sunysb.edu
  729.  
  730. +++++++++++++++++++++++++++
  731.  
  732. From: wysocki@husc.harvard.edu (Chris Wysocki)
  733. Date: 4 Apr 92 04:20:20 GMT
  734. Organization: Harvard University, Cambridge, MA
  735.  
  736. In article <1992Apr4.031947.6802@sbcs.sunysb.edu>, rhorn@csws15.ic.sunysb.edu
  737. (Robert Horn) writes:
  738.  
  739. > I'm writing a program, in which I have to get the icon for any 
  740. > file/folder/disk. I know how to get icons for everything except a hard drive
  741. > without a custom icon; I know that this information is in the hard drive's
  742. > driver, and that I should be able to access it through the Control() function,
  743. > ...
  744.  
  745. The following routine should do the trick; given a vRefNum, it returns a Handle
  746. to the icon for the corresponding volume: 
  747.  
  748. Handle GetVolumeIcon(short vRefNum)
  749. {
  750.     HParamBlockRec  hpb;
  751.     ParamBlockRec   pb;
  752.     Handle          iconH;
  753.     
  754.     hpb.volumeParam.ioNamePtr = NULL;
  755.     hpb.volumeParam.ioVRefNum = vRefNum;
  756.     hpb.volumeParam.ioVolIndex = 0;
  757.     FailOSErr(PBHGetVInfoSync(&hpb));
  758.     
  759.     pb.cntrlParam.ioVRefNum = hpb.volumeParam.ioVDrvInfo;
  760.     pb.cntrlParam.ioCRefNum = hpb.volumeParam.ioVDRefNum;
  761.     pb.cntrlParam.csCode = 21;
  762.     FailOSErr(PBControlSync(&pb))
  763.     FailOSErr(PtrToHand(*(Ptr *) pb.cntrlParam.csParam, &iconH, kLargeIconSize));
  764.     
  765.     return (iconH);
  766. }
  767.  
  768. Chris Wysocki
  769. wysocki@husc.harvard.edu
  770.  
  771.  
  772. ---------------------------
  773.  
  774. From: slej@vax5.cit.cornell.edu
  775. Subject: Very Early Macintosh Systre
  776. Date: 4 Apr 92 20:48:37 GMT
  777. Organization: Cornell University
  778.  
  779. This is not exactly a programming question, but it seemed the best forum
  780. I could find for my question. I'm interested (for a project) on older GUIs,
  781. in particular anything that might have been engineering prototypes for
  782. the current Macintosh, and also anything that may have gone into the 
  783. Lisa. Also, if anyone knows anything about any other "unusual" GUIs, I 
  784. would be interested in that too.
  785.  
  786. Thanks, MJH92
  787. (Mark Handel, slej@vax5.cit.cornell.edu)
  788.  
  789. +++++++++++++++++++++++++++
  790.  
  791. From: nagle@netcom.com (John Nagle)
  792. Date: 5 Apr 92 06:01:53 GMT
  793. Organization: Netcom - Online Communication Services  (408 241-9760 guest)
  794.  
  795.  
  796.        If you've never seen an operating Lisa, and have the opportunity,
  797. I recommend it.  The Mac, after all, is the cost-reduced version of the
  798. Lisa, and it shows.  The Lisa has a multi-tasking protected mode 
  799. operating system, and is in some ways more advanced than the Mac.
  800. It was just too expensive to build such a machine in 1982.
  801.  
  802.        Has anyone ever ported the Lisa environment to modern hardware?
  803. It would be fun to see the Lisa software running on a 68040.
  804.  
  805.                     John Nagle
  806.  
  807. ---------------------------
  808.  
  809. From: geck@plasma.icsl.ucla.edu (William Ross Geck)
  810. Subject: GWorld Woes
  811. Date: 4 Apr 92 21:03:36 GMT
  812. Organization: University of California at Los Angeles, EE Dept.
  813.  
  814. Hi All,
  815.  
  816.     I was wondering if somebody could tell my about the new GWorld routines.
  817. I want to create an offscreen graphics world to which I can assign three 
  818. different PixMap's.  While doing this, I have already learned the following:  
  819.  
  820. (1) The NewGWorld routine creates a pixMap of the appropriate size with 
  821.     (**pMap).baseAddr set to a Handle containing the pixMap data rather than 
  822.     the normal pointer.  (Aside: This is fine with me, I do the same for my 
  823.     own pixMaps.  I then lock and dereference the baseAddr before drawing to 
  824.     it, then do a "RestoreHandle" on it afterwards.  The LockPixels function 
  825.     does this same dereferencing when called before drawing anything to the 
  826.     port. And yes, I know that's why we should always use GetPixBaseAddr.)
  827.     
  828. (2) After calling LockPixels, I did an HGetState on the pixMapHandle, and on 
  829.     the pixMap data (now dereferenced) and found no bits set (AND no MemError).
  830.     Yet the Swatch application informs me that these structures are indeed 
  831.     locked!
  832.     
  833.     Question:  why doesn't HGetState tell me that these handles are locked? 
  834.  
  835. (3) I discovered that SetPortPix() takes as an argument a PixMapHandle rather 
  836.     than a pointer to a PixMapHandle as THINK Reference says!  
  837.     
  838. (4) I did the following:
  839.         1. pPix = GetGWorldPixMap( gPort );
  840.         2. ePix = NewPixMap();
  841.         3. CopyPixMap( pPix, ePix );
  842.         4. size = GetHandleSize( (Handle)(**pPix).baseAddr );
  843.         5. (**ePix).baseAddr = (Ptr)NewHandle( size );
  844.     To set up a second PixMap IDENTICAL to the GWorld's.  I then called 
  845.     SetPortPix( ePix ), locked ePix and (**ePix).baseAddr, dereferenced the 
  846.     baseAddr then tried to draw into the GWorld.  BOMB!!!!  I even replaced 
  847.     step #5 with a NewPtr call (In other words, made this a normal pixMap), 
  848.     BOMB!!!  
  849.     
  850.     Oh, "size" is set right, 193,920 Bytes if it matters, depth is 4.  The 
  851.     port is set to the GWorld.  There are NO memory errors (I check after every
  852.     memory manager call).  Before the SetPortPix I can draw into pPix (the
  853.     Original GWorld) without any problems.  I've rebuilt the project itself: 
  854.     no change.  By the way, I'm using THINK C 5.0.2 and System 7.0 with TuneUp.
  855.     
  856. Can anyone help me out?
  857.  
  858. W. Ross Geck
  859. geck@plasma.icsl.ucla.edu
  860.  
  861. +++++++++++++++++++++++++++
  862.  
  863. From: eric_berdahl@taligent.com (Eric Berdahl)
  864. Date: 7 Apr 92 00:42:00 GMT
  865. Organization: Taligent, Inc.
  866.  
  867. In article <6584@lee.SEAS.UCLA.EDU>, geck@plasma.icsl.ucla.edu (William Ross
  868. Geck) writes:
  869. > Hi All,
  870.  
  871. Hi William!
  872.  
  873. > (1) The NewGWorld routine creates a pixMap of the appropriate size with 
  874. >     (**pMap).baseAddr set to a Handle containing the pixMap data rather than 
  875. >     the normal pointer.  (Aside: This is fine with me, I do the same for my 
  876. >     own pixMaps.  I then lock and dereference the baseAddr before drawing to 
  877. >     it, then do a "RestoreHandle" on it afterwards.  The LockPixels function 
  878. >     does this same dereferencing when called before drawing anything to the 
  879. >     port. And yes, I know that's why we should always use GetPixBaseAddr.)
  880.  
  881. Sounds reasonable that the GWorld routines do this, and it's cool that you have
  882. found this special knowledge becuase you now understand GWorlds a little better
  883. than the average bear (as Yogi would put it).
  884.  
  885. > (2) After calling LockPixels, I did an HGetState on the pixMapHandle, and on 
  886. >     the pixMap data (now dereferenced) and found no bits set (AND no
  887. MemError).
  888. >     Yet the Swatch application informs me that these structures are indeed 
  889. >     locked!
  890. >     
  891. >     Question:  why doesn't HGetState tell me that these handles are locked? 
  892.  
  893. Good question.  I don't know why this doesn't happen, but I don't think it's
  894. anything to worry about.  I've been using GWorlds in my apps for a long time,
  895. and they've always worked.  I think we may be trying to understand the
  896. implementation at too fine a grain here.
  897.  
  898. > (4) I did the following:
  899. >         [code deleted]
  900. >     To set up a second PixMap IDENTICAL to the GWorld's.  I then called 
  901.                                 ^^^^^^^^^
  902. Apparently, it wasn't identical.
  903.  
  904. >     SetPortPix( ePix ), locked ePix and (**ePix).baseAddr, dereferenced the 
  905. >     baseAddr then tried to draw into the GWorld.  BOMB!!!!  I even replaced 
  906. >     step #5 with a NewPtr call (In other words, made this a normal pixMap), 
  907. >     BOMB!!!  
  908.  
  909. To create an identical PixMap (at least, as far as you need), create another
  910. GWorld with the same characteristics as the GWorld you want to copy (size, bit
  911. depth, color table, device, etc).  Basically, you have to treat all the fields
  912. of the GWorld as completely private.  You are not allowed to even look at the
  913. values because their use is not documented except to say that they may be
  914. different than the way the rest of the toolbox works.
  915.  
  916. Also, I try to avoid SetPortPix and NewPixMap for basically just this reason. 
  917. The only time I use PixMaps instead of GWorlds is if I need to CopyBits
  918. somewhere given a specific digital image with a specific color table.  Then I
  919. create a PixMap on the stack and CopyBits from it to a GWorld for more permanent
  920. storage.
  921.  
  922. Hope this helps.
  923. - --
  924. Eric Berdahl
  925. Taligent, Inc.
  926. Internet: eric_berdahl@taligent.com
  927. AppleLink: BERDAHL
  928. #include <StdDisclaimer.h>
  929. This is a freeware signature.  What do you expect for nothing?
  930.  
  931.  
  932. +++++++++++++++++++++++++++
  933.  
  934. From: eric_berdahl@taligent.com (Eric Berdahl)
  935. Date: 7 Apr 92 00:42:00 GMT
  936. Organization: Taligent, Inc.
  937.  
  938. In article <6584@lee.SEAS.UCLA.EDU>, geck@plasma.icsl.ucla.edu (William Ross
  939. Geck) writes:
  940. > Hi All,
  941.  
  942. Hi William!
  943.  
  944. > (1) The NewGWorld routine creates a pixMap of the appropriate size with 
  945. >     (**pMap).baseAddr set to a Handle containing the pixMap data rather than 
  946. >     the normal pointer.  (Aside: This is fine with me, I do the same for my 
  947. >     own pixMaps.  I then lock and dereference the baseAddr before drawing to 
  948. >     it, then do a "RestoreHandle" on it afterwards.  The LockPixels function 
  949. >     does this same dereferencing when called before drawing anything to the 
  950. >     port. And yes, I know that's why we should always use GetPixBaseAddr.)
  951.  
  952. Sounds reasonable that the GWorld routines do this, and it's cool that you have
  953. found this special knowledge becuase you now understand GWorlds a little better
  954. than the average bear (as Yogi would put it).
  955.  
  956. > (2) After calling LockPixels, I did an HGetState on the pixMapHandle, and on 
  957. >     the pixMap data (now dereferenced) and found no bits set (AND no
  958. MemError).
  959. >     Yet the Swatch application informs me that these structures are indeed 
  960. >     locked!
  961. >     
  962. >     Question:  why doesn't HGetState tell me that these handles are locked? 
  963.  
  964. Good question.  I don't know why this doesn't happen, but I don't think it's
  965. anything to worry about.  I've been using GWorlds in my apps for a long time,
  966. and they've always worked.  I think we may be trying to understand the
  967. implementation at too fine a grain here.
  968.  
  969. > (4) I did the following:
  970. >         [code deleted]
  971. >     To set up a second PixMap IDENTICAL to the GWorld's.  I then called 
  972.                                 ^^^^^^^^^
  973. Apparently, it wasn't identical.
  974.  
  975. >     SetPortPix( ePix ), locked ePix and (**ePix).baseAddr, dereferenced the 
  976. >     baseAddr then tried to draw into the GWorld.  BOMB!!!!  I even replaced 
  977. >     step #5 with a NewPtr call (In other words, made this a normal pixMap), 
  978. >     BOMB!!!  
  979.  
  980. To create an identical PixMap (at least, as far as you need), create another
  981. GWorld with the same characteristics as the GWorld you want to copy (size, bit
  982. depth, color table, device, etc).  Basically, you have to treat all the fields
  983. of the GWorld as completely private.  You are not allowed to even look at the
  984. values because their use is not documented except to say that they may be
  985. different than the way the rest of the toolbox works.
  986.  
  987. Also, I try to avoid SetPortPix and NewPixMap for basically just this reason. 
  988. The only time I use PixMaps instead of GWorlds is if I need to CopyBits
  989. somewhere given a specific digital image with a specific color table.  Then I
  990. create a PixMap on the stack and CopyBits from it to a GWorld for more permanent
  991. storage.
  992.  
  993. Hope this helps.
  994. - --
  995. Eric Berdahl
  996. Taligent, Inc.
  997. Internet: eric_berdahl@taligent.com
  998. AppleLink: BERDAHL
  999. #include <StdDisclaimer.h>
  1000. This is a freeware signature.  What do you expect for nothing?
  1001.  
  1002.  
  1003. ---------------------------
  1004.  
  1005. From: diessel@informatik.unibw-muenchen.de (Thomas Diessel)
  1006. Subject: Looking for C++ Compiler for Mac
  1007. Date: 5 Apr 92 14:06:19 GMT
  1008. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  1009.  
  1010. I'm looking for a C++ compiler for the Mac. The only C++ compiler I've
  1011. heard of is the Zortech C++. But I would prefere a compiler that doesn't
  1012. require MPW, e.g. THINK C. So, my questions qre:
  1013. Can you recommend the Zortech C++ compiler?
  1014. Are there other C++ compilers? (especially PD, e.g. GNU g++)
  1015. Will there be a THINK C++? (I know that Symantec has bought Zortech.)
  1016.  
  1017. Thomas Diessel
  1018. Federal Armed Forces University, Munich
  1019. Computer Science Dept.
  1020. Werner-Heisenberg-Weg 39
  1021. W-8014 Neubiberg
  1022. Germany
  1023. diessel@informatik.unibw-muenchen.de
  1024.  
  1025. +++++++++++++++++++++++++++
  1026.  
  1027. From: cory@enigami.mv.com (Cory Kempf)
  1028. Date: Sun, 5 Apr 92 22:17:38 EST
  1029. Organization: EnigamI, Inc., Nashua, NH
  1030.  
  1031.  
  1032. In article <diessel.702482779@gretchen> (comp.sys.mac.programmer), diessel@informatik.unibw-muenchen.de (Thomas Diessel) writes:
  1033. >I'm looking for a C++ compiler for the Mac. The only C++ compiler I've
  1034. >heard of is the Zortech C++. But I would prefere a compiler that doesn't
  1035. >require MPW, e.g. THINK C. So, my questions qre:
  1036. >Can you recommend the Zortech C++ compiler?
  1037. >Are there other C++ compilers? (especially PD, e.g. GNU g++)
  1038. >Will there be a THINK C++? (I know that Symantec has bought Zortech.)
  1039.  
  1040. I just asked a question on the Zortech product.  Unfortunately, the
  1041. answer came back rather negative.  Maybe in a couple of years.
  1042.  
  1043. The only other C++ that is available on the Mac is MPW C++.  Think
  1044. has not yet produced a C++ compiler.  The best they have is an implimentation
  1045. of Apple's minimal object C.
  1046.  
  1047. +C
  1048.  
  1049.  
  1050. - -------------------------------------------------------------
  1051. Cory Kempf                    EnigamI, Inc.
  1052. cory@enigami.mv.com           ...!decvax!enigami!cory
  1053. Microsoft Free and Proud Of It!... 
  1054.                            ...Microsoft Products: Just Say no.
  1055.  
  1056. ---------------------------
  1057.  
  1058. From: burglin@amber.mgh.harvard.edu (Thomas Burglin)
  1059. Subject: Macintosh C Programming primer examples (Q) Where?
  1060. Date: 6 Apr 92 06:31:00 GMT
  1061. Organization: Molecular Biology, Massachusetts General Hospital, Boston
  1062.  
  1063. Hi, I was wondering if any ftp site out there has at least some
  1064. of the example programs from the two books:
  1065. Macintosh C Programming Primer vol I & vol II.
  1066. Maybe not, since that might be an infringment on the copyright (I
  1067. didn't read the small print in the book).
  1068. But if anybody knows of some source for the example codes, 
  1069. I would appreciate the tip. (No, I don't want to pay megabucks
  1070. for the disk as advertised in the back of the book)
  1071. Thanks
  1072. Thomas Burglin
  1073. burglin@frodo.mgh.harvard.edu
  1074.  
  1075. +++++++++++++++++++++++++++
  1076.  
  1077. From: Carl.Constantine@BCSystems.GOV.BC.CA
  1078. Date: 7 Apr 92 14:49:17 GMT
  1079. Organization: BC Systems Corporation
  1080.  
  1081. In article <6APR199201310038@amber.mgh.harvard.edu>, burglin@amber.mgh.harvard.edu (Thomas Burglin) writes:
  1082. > Hi, I was wondering if any ftp site out there has at least some
  1083. > of the example programs from the two books:
  1084. > Macintosh C Programming Primer vol I & vol II.
  1085. > Maybe not, since that might be an infringment on the copyright (I
  1086. > didn't read the small print in the book).
  1087. > But if anybody knows of some source for the example codes, 
  1088. > I would appreciate the tip. (No, I don't want to pay megabucks
  1089. > for the disk as advertised in the back of the book)
  1090. > Thanks
  1091. > Thomas Burglin
  1092. > burglin@frodo.mgh.harvard.edu
  1093.  
  1094. I have most of the programs finished in Vol. 1 but I haven't started on Vol. 2
  1095. yet as I only have a Mac Plus (soon to be an LC II when my Tax return arrives)
  1096. so I can e-mail them to all who are interested.  Please send me e-mail directly
  1097. as I can't always read the news.
  1098.  
  1099. If anyone has a problem with this please let me know, otherwise I'm willing to
  1100. send them out.  I should be able to send them next week some time (April 13 or
  1101. so) as it will give me time to finish the last 4 programs in Vol. 1.
  1102.  
  1103.  
  1104.  
  1105. - -- 
  1106. Carl.Constantine@BCSystems.gov.bc.ca
  1107. Victoria, British Columbia, Canada
  1108.  
  1109. ---------------------------
  1110.  
  1111. From: meharp01@vlsi.louisville.edu (Michael Harpe)
  1112. Subject: Problem with THINK C 5.0.2 (long)
  1113. Date: 6 Apr 92 15:09:17 GMT
  1114. Organization: University of Louisville
  1115.  
  1116. I have two questions regarding a problem i'm seeing with THINK C 5.0.2.  I
  1117. am working on a program that reads in microprocessor cross assembler output
  1118. and does some processing with the decoded data.  For checksum calculations,
  1119. it's necessary to perform some math on a variable declared thus:
  1120.  
  1121. unsigned char rbyte;    /* should be an eight bit byte, true? */
  1122.  
  1123. and I want to read this byte from a buffer containing ASCII representations of
  1124. hex bytes: AAF3D345...  I should be able to do an sscanf:
  1125.  
  1126.     itemCount = sscanf(ptr,"%2X",&rbyte);    /* get a byte */
  1127.  
  1128. This should give me one of the bytes in rbyte, correct?  Well, the only way
  1129. I can get the behavior I expect is to change the unsigned char declaration
  1130. to an unsigned int.  Adding the byte I read to an unsigned char works 
  1131. correctly.  The problem is that sscanf is insisting on storing what it finds
  1132. in TWO bytes, not just one.  If it reads 0x23, it stores that as 0023 in two
  1133. locations.  I discovered this with the debugger.  Changing the field descriptor
  1134. to "%X" gives the same result.
  1135.  
  1136. That seems incorrect to me.  Taking this at face value, there appears to be
  1137. no way to interpret two ASCII characters to an unsigned char.  This works on
  1138. UNIX, that's where originally wrote the routine.  I have turned off the
  1139. THINK extensions and set up ANSI compliance.
  1140.  
  1141. OK, I found a workaround so what's the big deal?  Wellll, after I start this
  1142. processing loop, I want to display a dialog box that shows the progress I am
  1143. making through the file.  Given:
  1144.  
  1145. unsigned short objAddr = 0xE000;
  1146. unsigned short bytecnt = 35;
  1147. char strobjAddr = "\0";
  1148. char strbytecnt = "\0";
  1149.  
  1150. I should be able to:
  1151.  
  1152. itemCount = sprintf(strobjAddr,"%.4X",objAddr);
  1153. itemCount = sprintf(strbytecnt,"%.2u",bytecnt);
  1154.  
  1155. and end up with strobjAddr = "E000\0" and strbytecnt = "35\0".  NOT!  I had to
  1156. change the sprintf to read:
  1157.  
  1158. itemcount = sprintf(strobjAddr,"%.4lX",objaddr);
  1159. itemcount = sprintf(strbytecnt,"%.2lX",bytecnt);
  1160.  
  1161. Note that I had to make them BOTH read as longs before this worked.  I got
  1162. zeroes back with the first method.
  1163.  
  1164. Is this a compiler problem?  Or do I need more time with my C textbook (the 
  1165. latter being more likely).  The only reason I suspect this is that is seems
  1166. to contradict the typing rules.  Those are short integers so it seems kinda
  1167. silly to have to read them as longs.
  1168.  
  1169. Please respond directly to me.  If this is a really basic and silly mistake
  1170. I apologize in advance.  I would appreciate it if you would tell me so
  1171. in a constructive way, though :-).
  1172.  
  1173. Mike Harpe
  1174. University of Louisville
  1175.  
  1176. +++++++++++++++++++++++++++
  1177.  
  1178. From: pfeifer@alw.nih.gov (John Pfeifer)
  1179. Date: 6 Apr 92 19:38:39 GMT
  1180. Organization: National Inst. of Health, DCRT, CSL
  1181.  
  1182. Michael Harpe says:
  1183.  
  1184. > unsigned char rbyte;    /* should be an eight bit byte, true? */
  1185.  
  1186. Doesn't hafta be.
  1187.  
  1188. > and I want to read this byte from a buffer containing ASCII representations of
  1189. > hex bytes: AAF3D345...  I should be able to do an sscanf:
  1190. >
  1191. >    itemCount = sscanf(ptr,"%2X",&rbyte);    /* get a byte */
  1192.  
  1193. > This should give me one of the bytes in rbyte, correct?
  1194.  
  1195. Nope.  Read your manual (K&R p246 or THINK C: Standard Libraries Reference p60).  '%X'
  1196. returns you an int.  Same thing for printf.
  1197.  
  1198. - -John
  1199. - -- 
  1200. #include <stdsig.h>
  1201.  
  1202.         John Pfeifer                    internet: pfeifer@alw.nih.gov
  1203.  
  1204.     "The most creative and holy of men are always quite mad.
  1205.      It is simply a social thing as to wether one is sane or
  1206.      _insane_."                -The Madonna Vampira
  1207.  
  1208. +++++++++++++++++++++++++++
  1209.  
  1210. From: meharp01@vlsi.louisville.edu (Michael Harpe)
  1211. Date: 7 Apr 92 13:36:28 GMT
  1212. Organization: University of Louisville
  1213.  
  1214. Thanks to all who responded to this.  I just misunderstood the %X designator.
  1215. I had correctly deduced what was happening, I just didn't understand why it
  1216. was happening.  This cleared it up.  I cleaned up the code last night.
  1217.  
  1218. Source level debuggers are WONDERFUL learning tools.  It really helps to be
  1219. able to watch what happens and single-step through the program.
  1220.  
  1221. Actually, programming the Mac isn't as bad as I thought it would be.  The
  1222. books "Macintosh Programming Primer" are invaluable.  I would really be stuck
  1223. without them.  The net helps alot too :-).  I've been lurking on this group 
  1224. for some time and picked up a lot of tips here as well.
  1225.  
  1226. Thanks again.
  1227.  
  1228. Mike
  1229.  
  1230. ---------------------------
  1231.  
  1232. End of C.S.M.P. Digest
  1233. **********************
  1234.